package cn.com.jit;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class ReadSourceFiles {
    public static void main(String[] args) {
        String localPath = "/path/to/local/repository";
        File dir = new File(localPath);
        
        if (dir.exists() && dir.isDirectory()) {
            readFilesRecursively(dir);
        } else {
            System.out.println("Directory does not exist or is not a directory.");
        }
    }

    private static void readFilesRecursively(File dir) {
        File[] files = dir.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    readFilesRecursively(file);
                } else if (file.getName().endsWith(".java")) {
                    try {
                        String content = new String(Files.readAllBytes(Paths.get(file.getAbsolutePath())));
                        System.out.println("File: " + file.getName());
                        System.out.println(content);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
